home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_bas / mquery.zip / MPROFILE.FRM < prev    next >
Text File  |  1994-05-24  |  11KB  |  445 lines

  1. VERSION 2.00
  2. Begin Form fStoreQry 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Stored Query Manager"
  6.    ClientHeight    =   3960
  7.    ClientLeft      =   1290
  8.    ClientTop       =   2685
  9.    ClientWidth     =   4980
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   4365
  13.    Left            =   1230
  14.    LinkMode        =   1  'Source
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   3960
  19.    ScaleWidth      =   4980
  20.    Top             =   2340
  21.    Width           =   5100
  22.    Begin OptionButton OpSQLUser 
  23.       BackColor       =   &H00C0C0C0&
  24.       Caption         =   "Public:"
  25.       Height          =   240
  26.       Index           =   1
  27.       Left            =   465
  28.       TabIndex        =   7
  29.       Top             =   2250
  30.       Width           =   885
  31.    End
  32.    Begin OptionButton OpSQLUser 
  33.       BackColor       =   &H00C0C0C0&
  34.       Caption         =   "Private:"
  35.       Height          =   240
  36.       Index           =   0
  37.       Left            =   465
  38.       TabIndex        =   13
  39.       Top             =   1950
  40.       Value           =   -1  'True
  41.       Width           =   915
  42.    End
  43.    Begin CommandButton DeleteBtn 
  44.       Cancel          =   -1  'True
  45.       Caption         =   "&Delete"
  46.       Height          =   375
  47.       Left            =   3735
  48.       TabIndex        =   12
  49.       Top             =   3060
  50.       Width           =   1035
  51.    End
  52.    Begin SSPanel msgpanel 
  53.       Align           =   2  'Align Bottom
  54.       BevelInner      =   1  'Inset
  55.       Height          =   420
  56.       Left            =   0
  57.       TabIndex        =   6
  58.       Top             =   3540
  59.       Width           =   4980
  60.    End
  61.    Begin ListBox cqueries 
  62.       BackColor       =   &H00C0C0C0&
  63.       ForeColor       =   &H00000000&
  64.       Height          =   1005
  65.       Left            =   570
  66.       Sorted          =   -1  'True
  67.       TabIndex        =   11
  68.       TabStop         =   0   'False
  69.       Top             =   390
  70.       Width           =   3855
  71.    End
  72.    Begin CommandButton BtnQuit 
  73.       Caption         =   "&Quit"
  74.       Height          =   375
  75.       Left            =   2520
  76.       TabIndex        =   5
  77.       Top             =   3060
  78.       Width           =   1035
  79.    End
  80.    Begin CommandButton BtnRead 
  81.       Caption         =   "&Load"
  82.       Height          =   375
  83.       Left            =   1305
  84.       TabIndex        =   4
  85.       Top             =   3060
  86.       Width           =   1035
  87.    End
  88.    Begin CommandButton BtnWrite 
  89.       Caption         =   "&Save"
  90.       Height          =   375
  91.       Left            =   120
  92.       TabIndex        =   3
  93.       Top             =   3060
  94.       Width           =   1035
  95.    End
  96.    Begin TextBox TxtKey 
  97.       BackColor       =   &H00C0C0C0&
  98.       Height          =   375
  99.       Left            =   1500
  100.       TabIndex        =   2
  101.       Top             =   2520
  102.       Width           =   2895
  103.    End
  104.    Begin TextBox TxtSection 
  105.       BackColor       =   &H00C0C0C0&
  106.       Height          =   375
  107.       Left            =   1500
  108.       TabIndex        =   1
  109.       TabStop         =   0   'False
  110.       Top             =   2040
  111.       Width           =   2895
  112.    End
  113.    Begin TextBox TxtINIFile 
  114.       BackColor       =   &H00C0C0C0&
  115.       Enabled         =   0   'False
  116.       Height          =   375
  117.       Left            =   1500
  118.       TabIndex        =   0
  119.       TabStop         =   0   'False
  120.       Top             =   1560
  121.       Width           =   2895
  122.    End
  123.    Begin Label lblQueries 
  124.       Alignment       =   2  'Center
  125.       AutoSize        =   -1  'True
  126.       BackColor       =   &H00C0C0C0&
  127.       Caption         =   "Select Query"
  128.       Height          =   195
  129.       Left            =   540
  130.       TabIndex        =   9
  131.       Top             =   210
  132.       Width           =   1125
  133.    End
  134.    Begin Label LblKey 
  135.       Alignment       =   1  'Right Justify
  136.       AutoSize        =   -1  'True
  137.       BackColor       =   &H00C0C0C0&
  138.       Caption         =   "Query Name:"
  139.       Height          =   195
  140.       Left            =   285
  141.       TabIndex        =   8
  142.       Top             =   2640
  143.       Width           =   1110
  144.    End
  145.    Begin Label LblINIFile 
  146.       Alignment       =   1  'Right Justify
  147.       AutoSize        =   -1  'True
  148.       BackColor       =   &H00C0C0C0&
  149.       Caption         =   "Storage:"
  150.       Height          =   195
  151.       Left            =   690
  152.       TabIndex        =   10
  153.       Top             =   1620
  154.       Width           =   735
  155.    End
  156. End
  157. Dim FwriteFlag As Integer ' did I   write
  158. Dim Fdelstr As String
  159. Dim FSection As String
  160. Dim fDefaultuser As String
  161.  
  162. Sub BtnQuit_Click ()
  163. ' written or quit
  164. If FwriteFlag Then ' stored query
  165. FwriteFlag = False
  166. End If
  167. gstDynaString = ""
  168.  
  169. ' was this a stored query that was run
  170. If Not gStoredFlag Then     'not from storage
  171.     fQuery!RunSaveQryButton.Enabled = True
  172.     fQuery!RunQueryButton.Enabled = False
  173.         If gfFROMSQL Then  ' was a SQL Statement?
  174.             fQuery!RunQueryButton.Enabled = False
  175.         End If
  176. Else
  177.     fQuery!RunSaveQryButton.Enabled = True
  178. End If
  179. Unload Me
  180. End Sub
  181.  
  182. Sub BtnRead_Click ()
  183.     If TxtINIFile.Text = "" Then
  184.         Beep
  185.         TxtINIFile.SetFocus
  186.         Exit Sub
  187.     End If
  188.     
  189.     If TxtSection.Text = "" Then
  190.         Beep
  191.         TxtSection.SetFocus
  192.         Exit Sub
  193.     End If
  194.     
  195.     If Txtkey.Text = "" Then
  196.         Beep
  197.         Txtkey.SetFocus
  198.         Exit Sub
  199.     End If
  200.     
  201.     
  202.     'Assign textbox contents to variables for API call.
  203.     '(API call won't take references to Textbox contents.)
  204.     Sectn$ = TxtSection.Text
  205.     Keyy$ = Txtkey.Text
  206.     DeeFalt$ = ""
  207.     FileNam$ = gWindowsDirectory + "\" + TxtINIFile.Text
  208.     
  209.      gstDynaString = StringfromPrivINI(Sectn$, Keyy$, DeeFalt$, FileNam$)
  210.     
  211.     If gstDynaString = "" Then
  212.         msgpanel.Caption = "Section, Key or File name not found."
  213.     Else
  214.          
  215.          
  216.           fQuery!RunSaveQryButton.Enabled = False
  217.           DeleteBtn.Enabled = True
  218.          Unload Me
  219.     End If
  220.     
  221. End Sub
  222.  
  223. Sub BtnWrite_Click ()
  224.      FwriteFlag = False
  225.      DeleteBtn.Enabled = False
  226.     If TxtSection.Text = "" Then
  227.         Beep
  228.         TxtSection.SetFocus
  229.         Exit Sub
  230.     End If
  231.  
  232.     If Txtkey.Text = "" Then
  233.         Beep
  234.         Txtkey.SetFocus
  235.         Exit Sub
  236.     End If
  237.     
  238.     ' clear out GstDynaString if it has carriage return and linefeeds
  239.     ' pasted or otherwise inserted
  240.     a% = 0
  241.     For y% = 1 To Len(gstDynaString) - 2
  242.     a% = InStr(y% + a%, gstDynaString, Chr(13) + Chr(10))
  243.             If a% Then
  244.                 gstDynaString = Left(gstDynaString, a% - 1) + " " + Mid(gstDynaString, a% + 2, Len(gstDynaString))
  245.             End If
  246.     Next y%
  247.  
  248.  
  249.     Sectn$ = TxtSection.Text
  250.     Keyy$ = Txtkey.Text
  251.     Valyue$ = gstDynaString
  252.     FileNam$ = gWindowsDirectory + "\" + TxtINIFile.Text
  253.  
  254.     Result% = StringtoPrivINI(Sectn$, Keyy$, Valyue$, FileNam$)
  255.     If Result% = 0 Then
  256.          msgpanel.Caption = "QUERY NOT SAVED."
  257.     Else
  258.          msgpanel.Caption = "QUERY SAVED."
  259.          FwriteFlag = True
  260.     End If
  261.     gstDynaString = ""
  262. End Sub
  263.  
  264. Sub cqueries_Click ()
  265. If gstDynaString = "" Then
  266. Txtkey.Text = cqueries.List(cqueries.ListIndex)
  267. BtnRead.Enabled = True
  268. DeleteBtn.Enabled = True
  269. msgpanel.Caption = "QUERY SELECTED ...LOAD OR DELETE OR QUIT."
  270. End If
  271. End Sub
  272.  
  273. Sub cqueries_KeyPress (keyascii As Integer)
  274. keyascii = 0
  275. End Sub
  276.  
  277. Sub DeleteBtn_Click ()
  278. Fdelstr = Txtkey.Text
  279. If MsgBox("Delete " & Fdelstr & " ?", MSGBOX_TYPE) = YES Then
  280. delquery
  281. Unload Me
  282. End If
  283. End Sub
  284.  
  285. Sub delquery ()
  286. Dim f As String
  287. Dim h As String
  288. Dim a As Integer
  289. Dim b As Integer
  290. Dim filein As String
  291. Dim fileout As String
  292. On Error GoTo errorhere
  293.  
  294.  
  295. a = InStr(1, TxtINIFile.Text, ".")
  296.  
  297. filein = gWindowsDirectory + "\" + TxtINIFile.Text
  298. fileout = gWindowsDirectory + "\" + Left(TxtINIFile, a) + "bak"
  299. h = FSection
  300. Open filein For Input As 1
  301. Open fileout For Output As 2
  302. h = Fdelstr
  303. a = 0
  304. Do Until a > 0
  305.     Line Input #1, f
  306.     a = InStr(1, f, FSection)
  307.     Print #2, f
  308. Loop
  309.  
  310. Do Until EOF(1)
  311.      Line Input #1, f
  312.      a = InStr(1, f, h)
  313.      b = InStr(1, f, "[")
  314.      If b = 1 Then ' found new section
  315.         Print #2, f
  316.         h = "XXXXXX"
  317.      Else
  318.          If a = 0 Then
  319.          Print #2, f
  320.          End If
  321.      End If
  322. Loop
  323.  
  324. closeem:
  325.         Close 1
  326.         Close 2
  327. Kill filein
  328. Name fileout As filein
  329. MsgBox Fdelstr & " Deleted", 48
  330. Exit Sub
  331. errorhere:
  332. MsgBox "Error " & Str(Err), 48
  333. Resume closeem
  334. End Sub
  335.  
  336. Sub Form_Load ()
  337.     fStoreQry.Left = (Screen.Width - fStoreQry.Width) / 2
  338.     fStoreQry.Top = (Screen.Height - fStoreQry.Height) / 2
  339.  
  340. '*******************************************************
  341. '*  FDefaultuser can be the user ID from a network     *
  342. '*  Then sections can be PUBLIC for all users and      *
  343. '*  Private for the individual.  This way someone      *
  344. '*  who has a particular query for the database        *
  345. '*  can share it with others.                          *
  346. '*******************************************************
  347.        
  348.        gWindowsDirectory = WinDir()
  349.        fDefaultuser = "SMYTHERE" ' from network ID if MU
  350.        gSQLUser = fDefaultuser
  351.        getsections
  352.     
  353.         BtnWrite.Enabled = False
  354.         BtnRead.Enabled = False
  355.         DeleteBtn.Enabled = False
  356.  
  357. If gstDynaString <> "" Then
  358. Txtkey.Text = ""
  359. BtnWrite.Enabled = True
  360. DeleteBtn.Enabled = False
  361. msgpanel.Caption = "Enter a Query Name then SAVE or QUIT"
  362. End If
  363.  
  364. End Sub
  365.  
  366. Sub getsections ()
  367. Dim a As Integer
  368. Dim b As Integer
  369. Dim f As String
  370. Dim filein As String
  371. FSection = gSQLUser
  372.  
  373. TxtSection.Text = FSection
  374. TxtINIFile.Text = "STOREQRY.INI"
  375.  
  376. filein = TxtINIFile.Text
  377.  
  378. On Error GoTo nofile
  379. Open gWindowsDirectory + "\" + TxtINIFile.Text For Input As 1
  380.  
  381. Do
  382.     Line Input #1, f
  383.     a = InStr(1, f, "[" + FSection + "]")
  384. Loop Until a > 0
  385. ' check to see why loop ended
  386. If a Then ' found the section
  387.     Do ' loop until no more keys
  388.             If EOF(1) Then
  389.                 Close 1
  390.                 Exit Sub
  391.             End If
  392.  
  393.         Line Input #1, f  ' read next line
  394.         a = InStr(1, f, "=") ' if true then we have a key and value
  395.             If a = 0 Then
  396.                     Close 1
  397.                     Exit Sub
  398.             End If
  399.             
  400.                 b = InStr(1, f, "=")  ' true so parse it
  401.                 cqueries.AddItem Left(f, b - 1) 'add query name to combo box
  402.     Loop
  403.     
  404. Else ' this database not here
  405. MsgBox gstDBname + " Not Found"
  406. Close 1
  407. Exit Sub
  408. End If
  409.  
  410. getout:
  411. Close 1
  412. Exit Sub
  413. nofile:
  414. If Err = 62 Then
  415. Resume getout
  416. Else
  417. MsgBox "error = " + Str(Err)
  418. Resume getout
  419. End If
  420.  
  421.  
  422.  
  423. End Sub
  424.  
  425. Sub opSQLUser_Click (Index As Integer)
  426. SQLUserSelect (Index)
  427. cqueries.Clear
  428. getsections' Form_Load
  429. End Sub
  430.  
  431. Sub SQLUserSelect (I As Integer)
  432. If I = 0 Then
  433.   gSQLUser = fDefaultuser
  434. Else
  435.   gSQLUser = "PUBLIC"
  436. End If
  437. End Sub
  438.  
  439. Sub TxtKey_KeyPress (keyascii As Integer)
  440. If gstDynaString = "" Then
  441. keyascii = 0
  442. End If
  443. End Sub
  444.  
  445.